//
//  MainTabViewController.swift
//  CardBag
//
//  Created by hl on 2019/5/15.
//  Copyright © 2019 hlznj. All rights reserved.
//

import UIKit

class MainTabViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        //卡包页
        let cardBagNav = setupVC(vc: CardbagVC.init(), image: "tabbar1G", selectedImage: "tabbar1", title: "卡包")

        //设置页
        let setupNav = setupVC(vc: SetupVC.init(), image: "tabbar2G", selectedImage: "tabbar2", title: "设置")

        self.viewControllers = [cardBagNav, setupNav]

        self.tabBar.tintColor = UIColor.init(hexString: "#405177")
    }

    func setupVC(vc: UIViewController, image: String, selectedImage: String, title: String) -> BaseNavigationController {

        vc.title = title

        let cardBagNav = BaseNavigationController.init(rootViewController: vc)

        cardBagNav.tabBarItem.image = UIImage.init(named: image)?.withRenderingMode(.alwaysOriginal)

        cardBagNav.tabBarItem.selectedImage = UIImage.init(named: selectedImage)?.withRenderingMode(.alwaysOriginal)

        cardBagNav.tabBarItem.title = title

//        cardBagNav.navigationBar.barTintColor = MainColor1
//        cardBagNav.navigationBar.isTranslucent = false
        let dict:NSDictionary = [NSAttributedString.Key.foregroundColor: UIColor.black,NSAttributedString.Key.font : UIFont.boldSystemFont(ofSize: 18)]
        //标题颜色
        cardBagNav.navigationBar.titleTextAttributes = dict as? [NSAttributedString.Key : AnyObject]

        return cardBagNav
    }
}
